<?php
class TextField extends FormElement {
	
	public static $text = 'text';
	public static $email = 'email';
	public static $url = 'url';
	public static $number = 'number';
	public static $date = 'date';
	public static $month = 'month';
	public static $week = 'week';
	public static $time = 'time';
	public static $datetime = 'datetime';
	public static $datetimeLocal = 'datetime-local';
	
	private $textFieldType;
	
	public function __construct($elementId, $labelText, $textFieldType = 'text') {
		
		parent::__construct($elementId, $labelText);
		$this->textFieldType = $textFieldType;
	}
	
	public function setTextFieldType($textFieldType) {
	
		$this->textFieldType = $textFieldType;
	}
	
	protected function renderElement() {
		
		$hiddenLabelClass = '';
		if ($this->labelVisibility == Label::$labelHidden) {
			$hiddenLabelClass = 'class="ui-hidden-accessible"'; 
		}
		
		$defaultValue = $this->getDefaultValue();
		if ($defaultValue != NULL) {
			$defaultValue = ' value="' . $defaultValue . '" ';
		}
		
		echo '<label for="', $this->elementId, '" ', $hiddenLabelClass, ' >', $this->labelText, '</label>';
		echo '<input type="', $this->textFieldType, '" name="', $this->elementId, '" ';
		echo $this->formatAttributes(), $defaultValue, '/>';
	}
	
}
?>